package com.rivulet.doj_backend.controller;

import com.rivulet.doj_backend.pojo.User;
import com.rivulet.doj_backend.service.CompetitionService;
import com.rivulet.doj_backend.service.EmailService;
import com.rivulet.doj_backend.tools.ResultFul;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@CrossOrigin(origins = {"http://localhost:8080", "null"})
@RestController
@RequestMapping(value = "/doj")
public class CompetitionController {

    @Autowired
    CompetitionService competitionService;

    @RequestMapping(value = ("/user/{user_id}/competition"),method = RequestMethod.POST)
    public ResultFul getCompetitionList(@PathVariable Integer user_id){
        ResultFul result=new ResultFul<Object>(100,competitionService.getCompetition(user_id));
        return result;
    }
    @RequestMapping(value = ("competition/{competition_id}/join/{user_id}"),method = RequestMethod.POST)
    public ResultFul addCompetition(@PathVariable Integer competition_id, @PathVariable Integer user_id) {
        return competitionService.addCompetition(competition_id, user_id);
    }

}
